//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class LinearShadeProperties : ShadeProperties
    {
        private double angle;

        private bool scaled;

        public double Angle
        {
            get { return angle; }
            set { angle = value; }
        }

        public bool Scaled
        {
            get { return scaled; }
            set { scaled = value; }
        }

        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("lin"))
            {
                Angle = c.GetOptionalInteger("ang", 0) / 60000d;
                Scaled = c.GetOptionalBoolean("scaled", false);
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("lin"))
            {
                c.SetOptionalInteger("ang", (int)(Angle * 60000), 0);
                c.SetBoolean("scaled", Scaled);
            }
        }
    }
}